﻿using System;
using System.Collections.Generic;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 获取产品列表详细
    /// </summary>
    public partial class GetProductListJson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datas = new List<object>();
            var name = Fq("CoName").SafeToString();
            var productCategoryId = Fq("CoProductCategoryId").SafeToInt();
            var model = Fq("CoModel").SafeToString();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();
            var isRecommend = Fq("CoIsRecommend").SafeToString();
            var productService = new ProductService();
            var table = productService.GetTable(name, model, productCategoryId, isRecommend, pageValue, rowsValue); object result = new { total = table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoProductId"].SafeToInt(),
                    CoName = table.Rows[i]["CoName"].SafeToString(),
                    CoNameEn = table.Rows[i]["CoNameEn"].SafeToString(),
                    CoIsRecommend = table.Rows[i]["CoIsRecommend"].SafeToString(),
                    CoProductCategoryId = table.Rows[i]["CoProductCategoryId"].SafeToString(),
                    CoNormalImage = table.Rows[i]["CoNormalImage"].SafeToString(),
                    CoSmallImage = table.Rows[i]["CoSmallImage"].SafeToString(),
                    CoCategoryName = table.Rows[i]["CoCategoryName"].SafeToString(),
                });
            }
            Json(result);
        }
    }
}